package com.qiantu.phone.ui.shotview;

import android.content.Context;
import android.text.TextUtils;

import com.qiantu.phone.R;
import com.qiantu.phone.widget.RollerShutterSeek;

import static com.qiantu.phone.ui.uiutil.LLDeviceUtil.STROKE_PERCENTAGE;

/**
 * @Author luzx
 * @Date 2022/1/10
 */
public class RollerShutterShotView extends BaseDeviceActView {
    private RollerShutterSeek rollerShutterSeek;

    public RollerShutterShotView(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.roller_shutter_shot_view;
    }

    @Override
    public void initView() {
        rollerShutterSeek = findViewById(R.id.roller_shutter_seek);
        rollerShutterSeek.setOnChangeListener(new RollerShutterSeek.OnChangeListener() {
            @Override
            public void onProgressChanged(int progress) {

            }

            @Override
            public void onStartTrackingTouch() {

            }

            @Override
            public void onValueChanged(int progress) {
                addAct(STROKE_PERCENTAGE, (100 - progress) + "");
            }
        });
    }

    @Override
    public void updateView() {
        //根据已保存动作指令集合更新UI
        String strokePercentage = getState(STROKE_PERCENTAGE, null);
        if (TextUtils.isEmpty(strokePercentage)) {
            rollerShutterSeek.isNotSet(true);
        } else {
            rollerShutterSeek.setProgress(100 - Integer.valueOf(strokePercentage));
        }
    }
}
